﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YiNing.UI.Controls;

namespace YiNing.Tools
{
    public class TestFlyLine
    {

        public double[] SensorData { get; set; }
        public int StartZ { get; set; }
        public int StartX { get; set; }
        public int EndX { get; set; }
        public int StartY { get; set; }
        public int EndY { get; set; }
        public int LineId { get; set; }

        public int IntervalX { get; set; }
        public int IntervalY { get; set; }
        /// <summary>
        /// 当前飞拍行的芯片，主要用于拼图
        /// </summary>
        public List<Die> CurrentRowDies { get; set; }
        /// <summary>
        /// 飞拍起点X距离圆心的偏移
        /// </summary>
        public int StartXOffsetWaferCenterX { get; set; }
        /// <summary>
        /// 飞拍终点X距离圆心的偏移
        /// </summary>
        public int EndXOffsetWaferCenterX { get; set; }
        /// <summary>
        /// 飞拍起点Y距离圆心的偏移
        /// </summary>
        public int StartYOffsetWaferCenterY { get; set; }
        /// <summary>
        /// 飞拍终点Y距离圆心的偏移
        /// </summary>
        public int EndYOffsetWaferCenterY { get; set; }

        /// <summary>
        /// 补偿的数据！！！！这里要注意int[Y,X]
        /// </summary>
        public int[,] CompensateData { get; set; }


        public TestFlyLine()
        {
        }

        public TestFlyLine(double sX, double eX, double y, int lineId = 0) : this()
        {
            StartX = Convert.ToInt32(sX);
            EndX = Convert.ToInt32(eX);
            StartY = Convert.ToInt32(y);
            LineId = lineId;
        }
        public TestFlyLine(int sX, int eX, int sY, int eY = 20181121, int lineId = 0) : this()
        {
            StartX = sX;
            EndX = eX;
            StartY = sY;
            if (eY == 20181121) eY = sY;
            else EndY = eY;
            LineId = lineId;
        }
        public TestFlyLine(int sZ, int sX, int eX, int sY, int eY, int intervalX, int intervalY, int lineId = 0) : this()
        {
            StartZ = sZ;
            StartX = sX;
            EndX = eX;
            StartY = sY;
            EndY = eY;
            LineId = lineId;
            IntervalX = intervalX;
            IntervalY = intervalY;
        }

        /// <summary>
        /// 计算所有的点位偏移圆心的距离
        /// </summary>
        /// <param name="waferCenter"></param>
        public void CalOffsetWaferCenter(Point waferCenter)
        {
            StartXOffsetWaferCenterX = StartX - waferCenter.X;
            EndXOffsetWaferCenterX = EndX - waferCenter.X;
            StartYOffsetWaferCenterY = StartY - waferCenter.Y;
            EndYOffsetWaferCenterY = EndY - waferCenter.Y;
        }

        /// <summary>
        /// 更新飞拍行的数据
        /// </summary>
        /// <param name="waferCenter"></param>
        public void UpdateFlylineByWaferCenter(Point waferCenter)
        {
            StartX = StartXOffsetWaferCenterX + waferCenter.X;
            EndX = EndXOffsetWaferCenterX + waferCenter.X;
            StartY = StartYOffsetWaferCenterY + waferCenter.Y;
            EndY = EndYOffsetWaferCenterY + waferCenter.Y;
        }
    }
}
